package com.hand.zc25650.service.impl;

import com.hand.zc25650.mapper.ItemMapper;
import com.hand.zc25650.pojo.Item;
import com.hand.zc25650.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemServiceImpl implements ItemService {
    @Autowired
    private ItemMapper itemMapper;
    @Override
    public List<Item> selectAll() {
        return itemMapper.selectAll();
    }

    @Override
    public boolean deleteItem(long itemId) {
        boolean flag=itemMapper.deleteItem(itemId)>0?true:false;
        return flag;
    }

    @Override
    public Item selectItem(long itemId) {
        return itemMapper.selectById(itemId);
    }

    @Override
    public boolean updateItem(Item item) {
        boolean flag=itemMapper.updateItem(item)>0?true:false;
        return flag;
    }

    @Override
    public boolean addItem(Item item) {
        String itemCode=itemMapper.selectMaxItemCode();
        Integer itemCode2=Integer.valueOf(itemCode);
        itemCode2++;
        item.setItemCode(itemCode2.toString());
        boolean flag=itemMapper.addItem(item)>0?true:false;
        return flag;
    }

    @Override
    public Item selectByMsg(Item item) {
        return itemMapper.selectByMsg(item);
    }
}
